import { apiResquest } from "./request.js";

const host = `oxsywjoh.http01.cn/learningplatform`; //服务器主机域名
export const httpBaseUrl = `https://${host}`; //HTTP请求服务器基本地址

//登录注册
//登录
export const login = (requestConfig) =>
    apiRequest("http://localhost:8080/learningplatform/login", { method: "POST", requestConfig });
//注册
export const register = (requestConfig) =>
    apiRequest(`${httpBaseUrl}/register`, { method: "POST", requestConfig });

//主页
//发帖
export const postDiscuss = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/discuss/add`, { method: "POST", requestConfig });
//查看帖子列表
export const getDiscussList = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/index?faculty=0&page=1&limit=10`, { method: "GET", requestConfig });
//查看图片
export const getImage = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/upload/:imagename`, { method: "GET", requestConfig });

//帖子详情页
export const discussDetail = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/discuss/detail/:discussPostId?page=1&limit=10`, { method: "GET", requestConfig });

//帖子总数
export const discussCount = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/rows?faculty=0`, { method: "GET", requestConfig });

//点赞
export const like = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/like`, { method: "POST", requestConfig });


//评论总数
export const commentCount = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/discuss/CommentCount/:discussPostId`, { method: "GET", requestConfig });

//评论
export const comment = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/comment/add/:discussPostId?content=hello&entityType=1&entityId=4&targetId=1`, { method: "POST", requestConfig });


//搜索
export const search = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/search?keyword=好&page=1&limit=10`, { method: "GET", requestConfig });

//用户
//查看用户信息
export const getUser = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/profile/:userId`, { method: "GET", requestConfig });

//退出登录
export const logout = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/logout`, { method: "GET", requestConfig });

//修改密码
export const updatePassword = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/update`, { method: "POST", requestConfig });


//消息
//私信列表
export const letterList = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/letter/list?page=1&limit=10`, { method: "GET", requestConfig });

//私信详情页
export const letterDetail = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/letter/detail/:conversationId?page=1&limit=10`, { method: "GET", requestConfig });

//发送私信
export const sendLetter = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/letter/send?toName=1940706150&content=Hello!`, { method: "POST", requestConfig });

//通知列表
export const noticeList = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/notice/list`, { method: "GET", requestConfig });

//查看系统消息
export const getNoticeDetail = (requestConfig) =>
    apiResquest(`${httpBaseUrl}/notice/detail/:topic?page=1&limit=10`, { method: "GET", requestConfig });


